package com.youlu.campus.web.order.service.pay;

import com.youlu.campus.base.order.enums.GoodsCodeEnum;
import com.youlu.campus.web.order.service.PaperCertificateOrderService;
import org.apache.commons.lang3.StringUtils;

/**
 * 用户钱包明细类型枚举值
 */
public enum PlaceOrderServiceEnum {

    PAPER_CERTIFICATE_SERVICE(GoodsCodeEnum.SIGN_PAPER_CERTIFICATE.getCode(), PaperCertificateOrderService.class);
    
    private String goodsCode;

    private Class clazz;

    public String getGoodsCode() {
        return goodsCode;
    }

    public void setGoodsCode(String goodsCode) {
        this.goodsCode = goodsCode;
    }

    public Class getClazz() {
        return clazz;
    }

    public void setClazz(Class clazz) {
        this.clazz = clazz;
    }

    PlaceOrderServiceEnum(String goodsCode, Class clazz) {
        this.goodsCode = goodsCode;
        this.clazz = clazz;
    }

    public static Class getClassByGoodsCode(String goodsCode) {
        if (StringUtils.isBlank(goodsCode)) {
            return null;
        }
        for (PlaceOrderServiceEnum typeEnum : PlaceOrderServiceEnum.values()) {
            if (typeEnum.getGoodsCode().equals(goodsCode)) {
                return typeEnum.getClazz();
            }
        }
        return null;
    }
}
